package com.zhaohang.cn.board;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;

/**
 * 作者: 赵航
 * 创建时间: 2018/8/13 9:52
 * 描述:
 */
public class NetReceiver extends BroadcastReceiver {

    private int netWorkState;
    private PrensentView mBaseActivty;

    public NetReceiver(PrensentView mianActivty){
        this.mBaseActivty = mianActivty;
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        // 如果相等的话就说明网络状态发生了变化
        if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
            netWorkState = NetUtil.getNetWorkState(context);
            // 接口回调传过去状态的类型
            mBaseActivty.onNetChange(netWorkState);
        }


    }
}
